var browseGoods = {//浏览过的商品 
	 
	 init:function( ){
	  browseGoods.list();
	 },
	 
	 
	//列出 物品浏览商品  
	list:function(){
		var dataStr = "target=browse";
		$.ajax({
		   type: "POST",
		   url: "/mygoods/getGoodsData.jspa",
		   data: dataStr,
		   dataType : 'json',
		   success: function(json){//评论或者回复 
			   		if(json.cart.cartVoList.length>0){
			   			browseGoods.showAllList(json.cart.cartVoList);
			   		}
			   }
		  })
		
	},	
	//显示所有的 
	showAllList:function(list){
		var result = '';
		var length = list.length >=6 ? 6 :list.length;
		for(var i = 0 ;i< length;i++){
		  result+= browseGoods.showSingle(i,list[i]);
		}
		document.getElementById('browseList').innerHTML= '<ul>'+result+'</ul>';
		//return result;
	},
	
	showSingle:function(index,goods ){//显示单个物品
		return '<li ><a title="'+goods.goodsName+'" href="/goods/'+goods.goodsId+'.html" target="_blank"><img src="'+goods.imgUrl+'"></a>&yen;'+goods.memberPrice+'</li> ' ;
	},
	clearAllBrowse:function(){
		var dataStr = "target=browse";
			$.ajax({
			   type: "POST",
			   url: "/mygoods/clearAllBrowse.jspa",
			   dataType : 'json',
			   success: function(json){ 
				   		if(json.flag ==1){
				   			document.getElementById('browseList').innerHTML="";
				   			alert("你的浏览记录已清空!");
				   		}
				   }
		  })
	}
}